package com.service.Authorization.service.impl;

import com.service.Authorization.entity.UserDeviceInfo;
import com.service.Authorization.dao.UserDeviceInfoDao;
import com.service.Authorization.service.UserDeviceInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户设备表(UserDeviceInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-08-10 16:14:37
 */
@Service("userDeviceInfoService")
public class UserDeviceInfoServiceImpl implements UserDeviceInfoService {
    @Resource
    private UserDeviceInfoDao userDeviceInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserDeviceInfo queryById(String id) {
        return this.userDeviceInfoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UserDeviceInfo> queryAllByLimit(int offset, int limit) {
        return this.userDeviceInfoDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userDeviceInfo 实例对象
     * @return 实例对象
     */
    @Override
    public UserDeviceInfo insert(UserDeviceInfo userDeviceInfo) {
        this.userDeviceInfoDao.insert(userDeviceInfo);
        return userDeviceInfo;
    }

    /**
     * 修改数据
     *
     * @param userDeviceInfo 实例对象
     * @return 实例对象
     */
    @Override
    public UserDeviceInfo update(UserDeviceInfo userDeviceInfo) {
        this.userDeviceInfoDao.update(userDeviceInfo);
        return this.queryById(userDeviceInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.userDeviceInfoDao.deleteById(id) > 0;
    }

    @Override
    public List<UserDeviceInfo> queryAll(UserDeviceInfo userDeviceInfo) {
        return userDeviceInfoDao.queryAll(userDeviceInfo);
    }

    @Override
    @Transactional
    public void updateBatch(List<UserDeviceInfo> collect) {
        userDeviceInfoDao.insertOrUpdateBatch(collect);
    }
}
